home *** CD-ROM | disk | FTP | other *** search
- //Shade Sample Script
- //
- //Copyright (C) 1998 ExpressionTools, Inc.
- //
- //----------------------------------------------------------------------------------------------------------------
-
- var ok = XShade.ShowMessageBox("このサンプルは螺旋状に球を配置するスクリプトです。", true);
- if (ok == true) {
- PutSpheres()
- }
-
- //実行前のメッセージを表示させない場合は、上の記述を削除して
- //この下の関数の先頭についているコメント記号を消してください。
-
- //PutSpheres();
-
- /****** Main Function ******/
- function PutSpheres() {
- var call_dialog1 = new Dialog1();
- if (call_dialog1.can_exe1) {
-
- XShade.Message("実行中...");
-
- //画面の更新を禁止する。
- XShade.InhibitUpdate();
-
- XShade.CreatePart();
-
- //球を配置していく。
- for (var i = 0; i < call_dialog1.number_t; i++) {
- XShade.CreateSphere(Math.cos(DegToRad(call_dialog1.rotate_s)*i)*call_dialog1.sphere_r*i, call_dialog1.sphere_r*i, Math.sin(DegToRad(call_dialog1.rotate_s)*i)*call_dialog1.sphere_r*i, call_dialog1.sphere_r);
- }
-
- XShade.Message("終了");
-
- //画面の更新をする。
- XShade.AllowUpdate();
-
- XShade.SelectParent(1);
- }
- else {return;}
- }
-
- //ダイアログを表示する。
- /****** Dialog Object1 ******/
- function Dialog1() {
- this.sphere_r = 10.0;
- this.rotate_s = 15;
- this.number_t = 50;
- this.can_exe1 = true;
-
- XShade.BeginDialog(0);// ダイアログのID番号が0以外の場合は初期設定ファイルにプロパティ値が保存される。
-
-
- //入力ダイアログボックス内にダイアログアイテムを追加する。
- XShade.AppendFloatDialogItem("球の半径"); // 識別番号は 0
- XShade.AppendIntDialogItem("角度(度)"); // 識別番号は 1
- XShade.AppendIntDialogItem("個数(個)"); // 識別番号は 2
-
-
- //それぞれのダイアログアイテムのプロパティを設定する。
- XShade.FloatPropertyValue(0) = this.sphere_r; // 実数入力ダイアログアイテムの初期設定
- XShade.IntPropertyValue(1) = this.rotate_s; // 整数入力ダイアログアイテムの初期設定
- XShade.IntPropertyValue(2) = this.number_t; // 整数入力ダイアログアイテムの初期設定
-
- var ok = XShade.AskDialog(); //ダイアログボックス内のok/Cancelボタンが押されたかを識別する。
- if (ok) {
- this.sphere_r = XShade.FloatPropertyValue(0);
- this.rotate_s = XShade.IntPropertyValue(1);
- this.number_t = XShade.IntPropertyValue(2);
- this.can_exe1 = true;
- }
- else {this.can_exe1 = false;}
- XShade.EndDialog(); //ダイアログボックス用に取得したメモリを開放する。
- }
-
- //角度をラジアンにする。
- /****** Degree To Radian ******/
- function DegToRad(degree) {
- return degree*(Math.PI/180);
- }